const joi = require('joi');
const validationMiddleware = require('../../middleware/validate');
const { dealNotEmpty } = require('../../utils/dberrordeal');
const tagController = require('../../controllers/good/tagController');
const router = require('koa-router')();
router.prefix('/tag');
const rulesSchema = {
    '/tag/addtag': joi.object({
        name: dealNotEmpty('标签名称'),
        type: dealNotEmpty('标签类型'),
    }),
    '/tag/puttag': joi.object({
        id: dealNotEmpty('标签id'),
        name: dealNotEmpty('标签名称'),
        type: dealNotEmpty('标签类型'),
    }),
    '/tag/gettag': joi.object({
        id: dealNotEmpty('标签id'),
    }),
    '/tag/deltag': joi.object({
        id: dealNotEmpty('标签id'),
    }),
};
router.post('/addtag', validationMiddleware(rulesSchema), tagController.createTag);
router.post('/puttag', validationMiddleware(rulesSchema), tagController.updateTag);
router.post('/deltag', validationMiddleware(rulesSchema), tagController.deleteTag);
router.post('/gettag', validationMiddleware(rulesSchema), tagController.getTagById);
router.post('/gettaglist', tagController.getTagList);
router.post('/gettagtypelist', tagController.getTagTypeList);


module.exports = router;